package me.keiwu.user.dao;

import me.keiwu.user.domain.UserStep;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

/**
 * Created by kei on 09/11/2017.
 */
public interface UserStepDao extends PagingAndSortingRepository<UserStep, Long> {

    @Query(value = "select * from user_step u where user_id = ?1 and days = ?2 limit 1", nativeQuery=true)
    UserStep findInSameDay(Long userId, Integer days);

    @Query(value = "select * from user_step u where user_id = ?1 and u.days >= ?2 and u.days <= ?3", nativeQuery=true)
    List<UserStep> findFromTo(Long userId, Integer fromDays, Integer toDays);

}
